package com.jy.wms.common.base;

import net.sf.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

/**
 * 打印快递面单
 */
public class ExpressSurfaceBill {

    /**
     * 打印快递面单
     * @param map
     *  lxr   联系人
     *  lxrdh 联系电话
     *  sheng 省
     *  shi   市
     *  dz    地址
     *  goodsTypes    货品类型
     *  sl    数量
     *  zl    重量
     *  tj    体积
     * @return
     */
    public static JSONObject print(Map<String,Object> map){
        JSONObject json = new JSONObject();
        json.put("partnerId",ckfhInfo.ckfh_partnerId.getType());
        json.put("net", ckfhInfo.ckfh_net.getType());
        json.put("partnerKey", ckfhInfo.ckfh_partnerKey.getType());
        json.put("kuaidicom", ckfhInfo.ckfh_kuaidicom.getType());
        json.put("kuaidinum", "");
        json.put("orderId", "");
        JSONObject sendMan = new JSONObject();
        sendMan.put("name", ckfhInfo.ckfh_sendMan_name.getType());
        sendMan.put("mobile", ckfhInfo.ckfh_sendMan_mobile.getType());
        sendMan.put("tel", ckfhInfo.ckfh_sendMan_tel.getType());
        sendMan.put("province", ckfhInfo.ckfh_sendMan_province.getType());
        sendMan.put("city", ckfhInfo.ckfh_sendMan_city.getType());
        sendMan.put("district", ckfhInfo.ckfh_sendMan_district.getType());
        sendMan.put("addr", ckfhInfo.ckfh_sendMan_addr.getType());
        sendMan.put("printAddr", ckfhInfo.ckfh_sendMan_printAddr.getType());
        sendMan.put("company", ckfhInfo.ckfh_sendMan_company.getType());
        json.put("sendMan", sendMan);
        JSONObject recMan = new JSONObject();
        recMan.put("name", map.get("lxr").toString());
        recMan.put("mobile", map.get("lxrdh").toString());
        recMan.put("province", map.get("sheng").toString());
        recMan.put("city", map.get("shi").toString());
        recMan.put("district", "");
        recMan.put("addr", "");
        recMan.put("printAddr", map.get("dz").toString());
        recMan.put("company", "");
        json.put("recMan", recMan);
        json.put("cargo", map.get("goodsTypes").toString());
        json.put("count", map.get("sl").toString());
        json.put("weight", map.get("zl").toString());
        json.put("volumn", map.get("tj").toString());
        json.put("payType", "");
        json.put("expType", ckfhInfo.ckfh_expType.getType());
        json.put("remark", "");
        json.put("valinsPay", new Double(0));
        json.put("collection", new Double(0));
        json.put("needChild",ckfhInfo.ckfh_needChild.getType());
        json.put("needBack", ckfhInfo.ckfh_needBack.getType());
        json.put("needTemplate", ckfhInfo.ckfh_needTemplate.getType());
        Long t = System.currentTimeMillis();
        String key = ckfhInfo.ckfh_key.getType();
        String secret = ckfhInfo.ckfh_secret.getType();
        Map<String, Object> params = new HashMap<String, Object>();
        String sign = MD5.encode(json.toString() + t + key + secret);
        params.put("method", "getElecOrder");
        params.put("param", json.toString());
        params.put("sign", sign);
        params.put("t", t.toString());
        params.put("key", key);
        String postData = "method=getElecOrder&param="+json.toString()+"&sign="+sign+"&t="+t+"&key="+key;
        return JSONObject.fromObject(Send.SMS(postData,"http://api.kuaidi100.com/eorderapi.do"));
    }
}
